﻿#ifndef CSensorSeriesCtrMange_H
#define CSensorSeriesCtrMange_H
/********************************************************************************
** @ Date:2025/01/06
** @ Author: HanJiaXin
** @ Description:声振温设备控制类
** @ Version:1.0.0
** @ ClassName:CSensorSeriesCtrMange
** @ Fun:
********************************************************************************/
#include <QThread>
#include "CDevDataSensorSeries.h"
#include "CSensorSeriesOper.h"

class CSensorSeriesCtrMange : public QThread
{
	Q_OBJECT

public:
	CSensorSeriesCtrMange(CDevDataSensorSeries* pDevData);
	~CSensorSeriesCtrMange();

	void ThreadStart();
	void ThreadStop();
	bool CtrDevice(SCtrInfo& stCtrInfo);
	bool CtrDeviceEx(SCtrInfo& stCtrInfo);

protected:
	void run() override;

private:
	void writePoint();//写测点
	void CSensorSeriesCtrMange::processChannelState(const SChannel& item);
	void CSensorSeriesCtrMange::processSensorState(const SChannel& item, int basePoint,
		bool sensorState, const QDateTime& sensorTime);
	int& CSensorSeriesCtrMange::getChannelErrNum(int channelNo);
	int CSensorSeriesCtrMange::getChannelStatePoint(int channelNo);
	int CSensorSeriesCtrMange::getSensorPoint(int channelNo, int basePoint);

private:
	QVector<SCtrInfo>m_vecCtrQueue;
	bool m_bShouldStop;
	bool m_bFrist;                           //是否是首次开启线程，防止重启启动设备的时候频繁创建线程
	std::atomic<bool>      m_bhread;         //线程状态
	int  m_nGetStateCount;					 //获取设备状态计数
	int  m_nGetHistoryDataCount;			 //获取历史数据计数
	QMutex   *m_pMutex;
	CSensorSeriesOper* m_pCtrOper;
	CDevDataSensorSeries *m_pDevData; //算法仓设备数据类
	int nChannel1ErrNum;
	int nChannel2ErrNum;
	int nChannel3ErrNum;
	int nChannel4ErrNum;
	int nChannel5ErrNum;
	int nChannel6ErrNum;
	int nChannel7ErrNum;
	int nChannel8ErrNum;
};

#endif